import numpy as np
import matplotlib.pyplot as plt
def loadTrajectory(file_name):
	file = open(file_name)
	line_len = 0
	for line in file:
		line_len += 1
	trajectory = np.zeros((line_len, 3))
	file.close()

	file = open(file_name)
	index = 0
	for line in file:
		item = str.split(line)
		trajectory[index, 0] = float(item[0])
		trajectory[index, 1] = float(item[1])
		trajectory[index, 2] = float(item[2])
		index += 1
	file.close()
	return trajectory

if __name__ == "__main__":
	given_point = loadTrajectory("SplineFiles/given_point.txt")
	spline_trajectory = loadTrajectory("SplineFiles/spline_trajectory.txt")

	plt.figure()
	plt.plot(given_point[:,0], given_point[:,1], 'ro', label='given point')
	plt.plot(spline_trajectory[:,0], spline_trajectory[:,1], 'g', label='spline trajectory')
	plt.title('cubic spline trajectory')
	plt.xlabel('t')
	plt.ylabel('sin(t')
	plt.legend()
	plt.grid()
	plt.savefig("spline_test.png")
	plt.show()
